package com.wnxy.pawnbackgroundsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wnxy.pawnbackgroundsystem.dao.BrandSortMapper;
import com.wnxy.pawnbackgroundsystem.entity.Brand;
import com.wnxy.pawnbackgroundsystem.entity.BrandSort;
import com.wnxy.pawnbackgroundsystem.service.IBrandSortService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class BrandSortServiceImpl extends ServiceImpl<BrandSortMapper, BrandSort> implements IBrandSortService {

    public List<Integer> getSortIds(Integer brandId){
        List<BrandSort> brandSorts = this.list(new QueryWrapper<BrandSort>().eq("brand_id", brandId));
        ArrayList<Integer> integers = new ArrayList<>();
        for(BrandSort bs:brandSorts){
            integers.add(bs.getSortId());
        }
        return integers;
    }

    public void delMany(List<Integer> intList){
        System.out.println(intList);
        for(Integer ii:intList){
            this.remove(new UpdateWrapper<BrandSort>().eq("sort_id",ii));
        }

    }
}
